package core;

import java.util.ArrayList;
import java.util.List;

import main.SYRRES;

public class SetUser {
	List<User> listUser;
	private int[] sumNote = new int[SYRRES.NB_NOTE];
	
	public SetUser() {
		listUser = new ArrayList<User>();
	}
	
	public int hasUser(String id) {
		for (int i = 0; i < listUser.size(); i++) {
			if (id.equals(listUser.get(i).getId())) {
				return i;
			}
		}
		return -1;
	}
	
	public int size() {
		return listUser.size();
	}
	
	public void addUser(String id) {
		listUser.add(new User(id));
	}
	
	public User getLastUser() {
		return listUser.get(listUser.size() - 1);
	}
	
	public User getUser(int pos) {
		return listUser.get(pos);
	}
	
	public void calculSumNote(int noteID) {
		int sum = 0;
		for (User user: listUser) {
			user.calculSumNote(noteID);
			sum += user.getSumNote(noteID);
		}
		sumNote[noteID] = sum;
	}
	
	public int getSumNote(int noteID) {
		return sumNote[noteID];
	}
}
